import { createRouter, createWebHashHistory } from 'vue-router'
const routes = [
    {
        path: '/',
        redirect: '/pdfList'
    },
    {
        path: '/pdfList',
        name: 'pdfList',
        meta: {
            title: 'pdf列表'
        },
        component: () => import('../view/PdfList.vue')
    },
    {
        path: '/latex',
        name: 'latex',
        meta: {
            title: 'latex'
        },
        component: () => import('../view/Latex.vue'),
    },
    {
        path: '/mark',
        name: 'mark',
        meta: {
            title: 'mark'
        },
        component: () => import('../view/Mark.vue'),
    },
    {
        path: '/katex',
        name: 'katex',
        meta: {
            title: 'katex'
        },
        component: () => import('../view/katex.vue'),
    },
    {
        path: '/editor',
        name: 'editor',
        meta: {
            title: 'editor'
        },
        component: () => import('../view/editor.vue'),
    }
]
const router = createRouter({
    history: createWebHashHistory(),
    routes
})
// 挂载路由导航守卫：to表示将要访问的路径，from表示从哪里来，next是下一个要做的操作
router.beforeEach((to, from, next) => {
    // 修改页面 title
    if (to.meta.title) {
      document.title = '龙猫工具 - ' + to.meta.title
    }
    return next()
  })

// 导出路由
export default router
